home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / speller2.zip / SPOBJS.H < prev    next >
C/C++ Source or Header  |  1995-02-06  |  4KB  |  187 lines

  1. #if !defined(__SPOBJS_H)
  2. #define __SPOBJS_H
  3.  
  4. #if !defined(__STDIO_H)
  5. #include <stdio.h>
  6. #endif
  7. #if !defined(__STRING_H)
  8. #include <string.h>
  9. #endif
  10. #if !defined(_XMSARRAY_H) && !defined (__WINDOWS_H)
  11. #include "xmm.h"
  12. #include "xms.h"
  13. #endif
  14. #if !defined (_EMSARRAY_H) && !defined (__WINDOWS_H)
  15. #include "ems.h"
  16. #endif
  17.  
  18. int max (int value1, int value2);
  19.  
  20. const int TYPOS_MATCH = 0x100,
  21.       PHONETIC_MATCH =0x200,
  22.       COMPLEX_MATCH = 0x400;
  23.  
  24. const int AUTO_MEMORY = -1,
  25.           XMS_MEMORY  =  0,
  26.           DISK_MEMORY =  1;
  27.  
  28. #define USER_DIC 1
  29. #define TEMP_DIC 2
  30.  
  31. #define LAST_LETTER  'z' - 'a'  // don't change it
  32.  
  33. extern const char *hiValue;
  34. #define  NSFX 31
  35. //extern char *sfx[NSFX];
  36. //extern const int ItemsInPage ;
  37.  
  38. #if !defined(__WINDOWS_H)
  39. enum Bool {FALSE=0,TRUE=1};
  40. #endif
  41.  
  42. typedef unsigned char Uchar;
  43. struct Symbol {
  44.          Uchar degree;
  45.          char name[1];
  46.      };
  47.  
  48.  
  49. class MatchTable {
  50.     public:
  51.         int size;
  52.         int count;
  53.         int error;
  54.         MatchTable(int sz,int dups=FALSE);
  55.         ~MatchTable();
  56.         int AddMatch(char*,int);
  57.         FindMatch(Symbol*);
  58.         int seekMatch(Symbol *);
  59.         void delMatch(int);
  60.                 Symbol * get(int i) {return table[i];}
  61.                 virtual void    PrintMatch();
  62.                 void clear();
  63.         int resize(int newSize);
  64.      protected:
  65.     Symbol** table;
  66.     int Compare(Symbol*,Symbol*);
  67.     int lower;
  68.     int duplicate;
  69. };
  70. struct element {
  71.    element* prev;
  72.    element* next;
  73.    element *lru_prev;
  74.    element *lru_next;
  75.    char name[16];
  76. };
  77.  
  78. class Table {
  79.   protected:
  80.     element** table;
  81.       int size;
  82.     int *collis;
  83.       int Hash(char*);
  84.     int probes;
  85.     element *head;
  86.     int maxsize;
  87.     int items;
  88.     public:
  89.     int modified;
  90.     Table(int sz=197,int msize=197);
  91.          ~Table();
  92.     element* insert(char*);
  93.     int      lookup(char*);
  94.         load (char*);
  95.         save (char*);
  96.         void    PrintTable();
  97. };
  98.  
  99.  
  100.  
  101. class SortedArray {
  102.     public:
  103.     int count;
  104.     int maxWordLen;
  105.     int modified;
  106.         int error;
  107.         SortedArray(int sz=16,int dt = 10);
  108.         ~SortedArray();
  109.         char* insert(char*);
  110.         lookup(char*);
  111.         char *get(int Index);
  112.         virtual load (char*);
  113.         virtual save (char*);
  114.         void clear();
  115.         void    Print();
  116.     protected:
  117.     char** table;
  118.       int size;
  119.     int delta;
  120.     int lower;
  121. };
  122.  
  123. class FastDictionary : public SortedArray
  124. {
  125.  
  126. public:
  127.  
  128.     FastDictionary( short aLimit, short aDelta ) :
  129.        SortedArray( aLimit, aDelta) {}
  130.     virtual save(char *name) {return SortedArray::save(name);}
  131.     virtual save(){if(Dname)
  132.             return    SortedArray::save(Dname);
  133.             else
  134.             return 0;}
  135.         setName(char *name);
  136.         protected:
  137.     char *Dname;
  138. };
  139. inline FastDictionary::setName(char *name)
  140. {
  141. if(name)
  142.         { Dname=new char[strlen(name)];
  143.           if (!Dname)
  144.                 return 0;
  145.           strcpy(Dname,name);
  146.           return 1;
  147.         }
  148. return 0;
  149. }
  150.  
  151.  
  152. ////////////////////////////////////////////
  153. //
  154. // class Xms dictionary
  155. //
  156. ////////////////////////////////////////////
  157. struct tagHeader {
  158. char sig[2];  // not used yet
  159. short int maxSize;  // max length of words
  160. long firstLetter[LAST_LETTER+1]; // index of A-Z in array
  161. long indexSize;
  162.  
  163. };
  164.  
  165.  
  166. struct tagAddHeader {
  167. long fileSize;//
  168. long index_offset;
  169. long ext_header_offset;
  170. short int data_offset;//
  171. } ;
  172.  
  173. struct tagCheader {
  174. long firstLetter[LAST_LETTER+2]; // index of A-Z in array
  175. short int index_count;
  176. };
  177.  
  178.  
  179. struct IndexNode
  180. {
  181.   long ptr;
  182.   long count;
  183.   char *name;
  184. } ;
  185.  
  186. #endif // __SPOBJS_H
  187.